<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title> - 亲友圈配置</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
	<link href="__STATIC__/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/css/new_file.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox ">
				<div class="ibox-title">
					<h5>亲友圈配置</h5>
				</div>
				<div class="toogl_body">
					<a href="Club.html"><button type="button" class="btn btn-w-m btn-bt btn-white">亲友圈管理</button></a>
					<a href="Club_configure.html"><button type="button" class="btn btn-w-m btn-white btn-bt">蓝钻商城配置</button></a>
					<a href="Club_goldcoin.html"><button type="button" class="btn btn-w-m btn-white btn-bt">黄钻商城配置</button></a>
					<a href="Club_vipcard.html"><button type="button" class="btn btn-w-m btn-white btn-bt">会员卡商城配置</button></a>
					<a href="Club_establish.html"><button type="button" class="btn btn-w-m btn-white btn-bt">创建亲友圈</button></a>
					<!--<a href="Club_grant.html"><button type="button" class="btn btn-w-m btn-bt btn-white">金币发放</button></a>-->
					<a href="Club_conf.html"><button type="button" class="btn btn-w-m btn-info btn-bt">亲友圈配置</button></a>
					<a href="Club_from.html"><button type="button" class="btn btn-w-m btn-white btn-bt">房间配置</button></a>
					<hr style="clear: both;"/>
					<a href="Club_conf.html"><button type="button" class="btn btn-w-m btn-info">VIP卡配置</button></a>
					<a href="Club_conf_1.html"><button type="button" class="btn btn-w-m btn-white">倍数配置</button></a>
					<div class="ibox-content ibox-jqGrid">
						<input type="button" value="添加卡VIP卡种类" class="btn btn-info" data-toggle="modal" data-target="#myModal2_2" />
						<!--添加新的VIP种类-->
						<div class="jqGrid_wrapper">
							<table id="table_list_1"></table>
							<div id="pager_list_1"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="myModal2_2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="col-sm-3 club_con">
		<div class="ibox club_tp">
			<div class="ibox-title">
				<h5>添加</h5>
				<div class="ibox-tools" data-dismiss="modal">
					<a class="close-link">
						<i class="fa fa-times"></i>
					</a>
				</div>
			</div>
			<div class="ibox-content float-pad">
				<div class="form-group form-group-tool">
					<label class="control-label">&nbsp;会员卡ID：</label>
					<input type="text" value="" id="vip_id" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">&nbsp;名称：</label>
					<input type="text" value="" id="name" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">天数：</label>
					<input type="text" value="" id="day" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">钻石消耗折扣：</label>
					<input type="text" value="" id="diamond" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="col-sm-3 control-label">icon：</label>
					<div class="col-sm-8 col-img">
						<div class="form-group">
							<div id="show"></div>
						</div>
						<div id="result"></div>
						<button class="btn btn-info" onclick="f.click()" type="button">更换</button>
						<input type="file" id="f" name="f" onchange="getPhoto(this);" style="display:none"/>
					</div>
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">价格上限：</label>
					<input type="text" value="" id="price_upper_limit" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">价格下限：</label>
					<input type="text" value="" id="price" class="form-control">
				</div>
				<div class="form-group form-group-tool">
					<label class="control-label">种类：</label>
					<input type="text" value="" id="type" class="form-control">
				</div>

			</div>
			<div class="ibox-butz">
				<input class="btn btn-w-m btn-info" type="button" id="button_ban_user" onclick="sc()" value="确定">
				<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消">
			</div>
		</div>
	</div>
</div>

<div id="myModal2_1" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div id="gray_Nr">
		<div class="col-sm-3 club_con">
			<div class="ibox club_tp">
				<div class="ibox-title">
					<h5>添加</h5>
					<div class="ibox-tools" data-dismiss="modal">
						<a class="close-link">
							<i class="fa fa-times"></i>
						</a>
					</div>
				</div>
				<div class="ibox-content float-pad">
					<div class="form-group form-group-tool">
						<label class="control-label">&nbsp;会员卡ID：</label>
						<input type="hidden" value="" id="id" class="form-control">
						<input type="text" value="" id="save_vip_id" class="form-control">
					</div>
					<div class="form-group form-group-tool">
						<label class="control-label">&nbsp;名称：</label>
						<input type="text" value="" id="save_name" class="form-control">
					</div>
					<div class="form-group form-group-tool">
						<label class="control-label">天数：</label>
						<input type="text" value="" id="save_day" class="form-control">
					</div>
					<div class="form-group form-group-tool">
						<label class="control-label">钻石消耗折扣：</label>
						<input type="text" value="" id="save_diamond" class="form-control">
					</div>
					<div class="form-group form-group-tool">
						<label class="col-sm-3 control-label">icon：</label>
						<div class="col-sm-8 col-img">
							<div class="form-group">
								<div id="show1"></div>
							</div>
							<div id="result1"></div>
							<button class="btn btn-info" onclick="fi.click()" type="button">更换</button>
							<input type="file" id="fi" name="fi" onchange="getPhoto1(this);" style="display:none"/>
						</div>
					</div>
					<div class="form-group form-group-tool">
						<label class="control-label">价格上限：</label>
						<input type="text" value="" id="save_price_upper_limit" class="form-control">
					</div>
					<div class="form-group form-group-tool">
						<label class="control-label">价格下限：</label>
						<input type="text" value="" id="save_price" class="form-control">
					</div>

				</div>
				<div class="ibox-butz">
					<input class="btn btn-w-m btn-info" type="button" id="button" onclick="save()" value="确定">
					<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消">
				</div>
			</div>
		</div>
	</div>
</div>
<!--手机导航-->
<div class="to-fdh" style="display: none;">
	<img class="to-imgd" src="__STATIC__/img/phonedh.jpg">
	<div class="mob-nrlb">
		<ul>
			<li>
				<a class="mob-nrdh">管理</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('Player/gameplayer')}">玩家管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('system/notice')}">公告管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('email/mail')}">邮件管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Club/club')}">亲友圈管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Money/money')}">提现管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('Order/order')}">订单管理</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh">数据</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('data/datagk')}">概況</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datawf')}">玩法</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datalc')}">留存</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/datass')}">实时数据</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataczfx')}">充值分析</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/dataclub')}">亲友圈统计</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/president')}">高级会长</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('data/regionaldata')}">地区数据</a>
					</li>
				</ul>
			</li>
			<li>
				<a class="mob-nrdh mob-qbh">权限</a>
				<ul class="mob-nryc">
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_list')}">权限管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('rule/rule_group')}">用户组管理</a>
					</li>
					<li class="mob-nrdhli">
						<a href="{:url('account/account_details')}">后台账号管理</a>
					</li>
				</ul>
			</li>
		</ul>
	</div>
</div>
<div id="zkbg">
	<img src="__STATIC__/img/dp.gif">
</div>
<div class="vnl-zz" style="display:none">
	<div><img src="__STATIC__/img/bqhp.gif"></div>
</div>
<!--手机适配-->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__STATIC__/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
<script src="__STATIC__/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>
<script src="__STATIC__/js/content.js?v=1.0.0"></script>
<script src="__STATIC__/js/plugins/laydate/laydate.js"></script>
<script src="__STATIC__/js/echarts.min.js"></script>
<script src="__STATIC__/js/echarts.common.min.js"></script>
<script>
    //手机适配
    $(function(){
        if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
            $("head").append("<link>");
            var css = $("head").children(":last");
            css.attr({
                rel:  "stylesheet",
                type: "text/css",
                href: "__STATIC__/css/phone_sp.css"
            });
            var mql = window.matchMedia("(orientation: portrait)");
            if(mql.matches) { //竖屏样式
                $(".vnl-zz").show();
                $(".to-fdh").hide();
            }else{
                $(".to-fdh").show();
                $("html").width("100%");
                $("body").width("100%");
            }
            mql.addListener(function(m) {
                if(m.matches) {
                    // 改变到直立方向
                    $(".vnl-zz").show();
                    $(".to-fdh").hide();
                }
                else {
                    $(".to-fdh").show();
                    $(".vnl-zz").hide();
                    $("html").width("100%");
                    $("body").width("100%");
                }
            });
        }
    });
    //导航显示展开
    $(".mob-nrdh").click(function(){
        $(this).next().toggle(".mob-nryc");
    });
    $(".to-imgd").click(function(){
        $(this).next().toggle(".mob-nrlb");
    });
    //手机适配end
    var imgurl = "";
    function getPhoto(node) {
        var imgURL = "";
        try{
            var file = null;
            if(node.files && node.files[0] ){
                file = node.files[0];
            }else if(node.files && node.files.item(0)) {
                file = node.files.item(0);
            }
            //Firefox 因安全性问题已无法直接通过input[file].value 获取完整的文件路径
            try{
                imgURL =  file.getAsDataURL();
            }catch(e){
                imgRUL = window.URL.createObjectURL(file);
            }
        }catch(e){
            if (node.files && node.files[0]) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    imgURL = e.target.result;
                };
                reader.readAsDataURL(node.files[0]);
            }
        }
        creatImg(imgRUL);
        // console.log(imgRUL);
        return imgURL;
    }

    function creatImg(imgRUL){
        var textHtml = "<img src='"+imgRUL+"'width='100%'/>";
        $('#result').html(textHtml);
    }
    function getPhoto1(node) {
        var imgURL = "";
        try{
            var file = null;
            if(node.files && node.files[0] ){
                file = node.files[0];
            }else if(node.files && node.files.item(0)) {
                file = node.files.item(0);
            }
            //Firefox 因安全性问题已无法直接通过input[file].value 获取完整的文件路径
            try{
                imgURL =  file.getAsDataURL();
            }catch(e){
                imgRUL = window.URL.createObjectURL(file);
            }
        }catch(e){
            if (node.files && node.files[0]) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    imgURL = e.target.result;
                };
                reader.readAsDataURL(node.files[0]);
            }
        }
        creatImg1(imgRUL);
        // console.log(imgRUL);
        return imgURL;
    }

    function creatImg1(imgRUL){
        var textHtml = "<img src='"+imgRUL+"'width='100%'/>";
        $('#result1').html(textHtml);
    }
</script>
<script>
    function sc(){
        var animateimg = $("#f").val(); //获取上传的图片名 带//
        var imgarr=animateimg.split('\\'); //分割
        var myimg=imgarr[imgarr.length-1]; //去掉 // 获取图片名
        var houzui = myimg.lastIndexOf('.'); //获取 . 出现的位置
        var ext = myimg.substring(houzui, myimg.length).toUpperCase();  //切割 . 获取文件后缀
        var file = $('#f').get(0).files[0]; //获取上传的文件
        var formdata = new FormData();
        if(file){
            var fileSize = file.size;
            //获取上传的文件大小
            // var maxSize = 1048576;              //最大1MB
            var maxSize = 18432;              //最大20KB
            // if(ext !='.PNG' && ext !='.GIF' && ext !='.JPG' && ext !='.JPEG' && ext !='.BMP'){
            if(ext !='.PNG' || parseInt(fileSize) >= parseInt(maxSize)){
                // alert('文件类型错误,请上传图片类型');
                alert('请上传不超过20K,PNG格式的图片');
                return false;
            }else{
                formdata.append('f',$('#f').get(0).files[0]);
            }
        }
        var vip_id = $("#vip_id").val();
        var name = $("#name").val();
        var day = $("#day").val();
        var diamond = $("#diamond").val();
        var price_upper_limit = $("#price_upper_limit").val();
        var price = $("#price").val();
        var type = $("#type").val();
        // if(notice.length > 30){
        //     $("#limit").html('限定30個漢字');
        //     $("#limit").css('color','red');
        //     // alert('限定30个汉字');
        //     return false;
        // }
        formdata.append('vip_id',vip_id);
        formdata.append('name',name);
        formdata.append('day',day);
        formdata.append('diamond',diamond);
        formdata.append('price',price);
        formdata.append('price_upper_limit',price_upper_limit);
        formdata.append('type',type);
        $.ajax({
            url: "{:url('Club/vip_add')}",
            type: 'POST',
            data: formdata,
            dataType: 'JSON',
            cache: false,
            processData: false,
            contentType: false
        }).done(function(ret){
            if(ret['isSuccess']){
                alert(ret.msg);
                location.reload();
            }else{
                alert('图片上传失败');
            }
        });

    }
    function save(){
        var animateimg = $("#fi").val(); //获取上传的图片名 带//
        var imgarr=animateimg.split('\\'); //分割
        var myimg=imgarr[imgarr.length-1]; //去掉 // 获取图片名
        var houzui = myimg.lastIndexOf('.'); //获取 . 出现的位置
        var ext = myimg.substring(houzui, myimg.length).toUpperCase();  //切割 . 获取文件后缀
        var file = $('#fi').get(0).files[0]; //获取上传的文件
        var formdata = new FormData();
        if(file){
            var fileSize = file.size;
            var maxSize = 102400;              //最大20KB
            // if(ext !='.PNG' && ext !='.GIF' && ext !='.JPG' && ext !='.JPEG' && ext !='.BMP'){
            if(ext !='.PNG' || parseInt(fileSize) >= parseInt(maxSize)){
                alert('请上传不超过100K,PNG格式的图片');
                return false;
            }else{
                formdata.append('f',$('#fi').get(0).files[0]);
            }
        }
        var id = $("#id").val();
        var vip_id = $("#save_vip_id").val();
        var name = $("#save_name").val();
        var day = $("#save_day").val();
        var diamond = $("#save_diamond").val();
        var price = $("#save_price").val();
        var price_upper_limit = $("#save_price_upper_limit").val();

        formdata.append('price_upper_limit',price_upper_limit);
        formdata.append('id',id);
        formdata.append('vip_id',vip_id);
        formdata.append('name',name);
        formdata.append('day',day);
        formdata.append('diamond',diamond);
        formdata.append('price',price);
        $.ajax({
            url: "{:url('Club/vip_save')}",
            type: 'POST',
            data: formdata,
            dataType: 'JSON',
            cache: false,
            processData: false,
            contentType: false
        }).done(function(ret){
            if(ret['isSuccess']){
                alert(ret.msg);
                location.reload();
            }else{
                alert('图片上传失败');
            }
        });

    }
    function del(t){
        var id = $(t).parent().parent().children().eq(0).html();//亲友圈id
        $.ajax({
            url:"{:url('club/vip_del')}",
            data:{"id":id},
            type:"POST",
            dataType: "json",
            success: function(e) {
                alert(e.msg);
                location.reload();
            },
            error: function(e) {
                // console.log(e);
                alert(e.msg);
            }
        })

    }
    function _getMessage(t){
        var id = $(t).parent().parent().children().eq(0).html();//亲友圈id
        var vip_id = $(t).parent().parent().children().eq(1).html();//亲友圈id
        var name = $(t).parent().parent().children().eq(2).html();//亲友圈id
        var day = $(t).parent().parent().children().eq(3).html();//亲友圈id
        var diamond = $(t).parent().parent().children().eq(4).html();//亲友圈id
        var price = $(t).parent().parent().children().eq(6).html();//亲友圈id
        var icon = $(t).parent().parent().children().eq(7).html();//亲友圈id
        var price_upper_limit  = $(t).parent().parent().children().eq(5).html();//亲友圈id
        var result = '';

        result += '<img src="' + '__ROOT__/' +icon + '" width="100">';
        $("#id").val(id);
        $("#save_vip_id").val(vip_id);
        $("#save_name").val(name);
        $("#save_day").val(day);
        $("#save_diamond").val(diamond);
        $("#save_price_upper_limit").val(price_upper_limit);
        $("#save_price").val(price);
        $("#result1").html(result);

    }
</script>
<script>

    $(document).ready(function () {

        $.jgrid.defaults.styleUI = 'Bootstrap';
        // Examle data for jqGri

        $("#table_list_1").jqGrid({
            url: "{:url('Club/vip_message')}",
            datatype:'json',
            postData:{}, //发送数据
            mtype: 'POST',
            height: 450,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 20,
            rowList: [20,50,100],
            colNames: ['id','会员卡ID', '名称', '天数','钻石消耗折扣','价格上限','价格下限','icon','种类','操作'],
            colModel: [
                {
                    name: 'id',
                    index: 'id',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'vip_id',
                    index: 'vip_id',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'name',
                    index: 'name',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'number_day',
                    index: 'number_day',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'diamond_consumption',
                    index: 'diamond_consumption',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'price_upper_limit',
                    index: 'price_upper_limit',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'price',
                    index: 'price',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'icon',
                    index: 'icon',
                    width: 60,
                    sorttype: "int",
                    hidden :true,
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'type',
                    index: 'type',
                    width: 60,
                    sorttype: "int",
                    sortable: false,
                    align:'center'
                },
                {
                    name: 'id',
                    index: 'id',
                    width: 60,
                    sorttype: "int",
                    formatter: function(club_status) {
                        return '<input type="button" value="修改" id="" data-toggle="modal" data-target="#myModal2_1" class="btn btn-info" onclick="_getMessage(this)"/><input type="button" value="删除" id="" data-toggle="modal" data-target="#myModal3" class="btn btn-danger" onclick="del(this)"/>';
                    },
                    align:'center'

                }
            ],
            pager: "#pager_list_1",
            viewrecords: true,
            caption: "亲友圈配置",
            loadonce: true,
            hidegrid: false
        });
        $("#jd").hide();
        $(function(){
            $("#jd").click(function(){
                $("#jd").hide();
                $("#dj").show();
            });
            $("#dj").click(function(){
                $("#dj").hide();
                $("#jd").show();
            });
        });
        $("#fj").hide();
        $(function(){
            $("#fj").click(function(){
                $("#fj").hide();
                $("#jj").show();
            });
            $("#jj").click(function(){
                $("#jj").hide();
                $("#fj").show();
            });
        });
        $('.form-conselein').hide();
        $('.form-consele').on('change',function(){
            if ($('.form-consele').val() == '0') {
                $('.form-conselein').hide();
            } else{
                $('.form-conselein').show();
            }
        })
      
        
		setTimeout(function(){
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
		},500);
        
        
        laydate.render({
            elem: '#time1'
            ,range: true
        });
        laydate.render({
            elem: '#time2'
            ,range: true
        });
    });
</script>


</body>

</html>